package com.lw.main.word;

import lombok.NoArgsConstructor;

import java.awt.*;

/**
 * 游戏计时
 */
public class GameTime {

    private long beginTime;//开始时间
    private long endTime;//结束时间
    private long differ;//时间差

    public void begin(){
        beginTime = System.currentTimeMillis();
    }

    public long diffTime(){
        endTime = System.currentTimeMillis();
        return differ = (endTime-beginTime)/1000;
    }

    public void draw(Graphics g){
        long differ = this.diffTime();
        g.setColor(Color.white);
        g.setFont(new Font("微软雅黑",Font.BOLD,20));
        g.drawString("坚持了"+differ+"秒",30,50);
    }

    public long getDiffer() {
        return differ;
    }
}
